package com.firefly.service.repository.cms;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.firefly.dao.dao.cms.po.CateRelationPo;
import com.firefly.dao.dao.cms.service.CateRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @description: 栏目关系
 * @author: lzg(萤火科技 ： 854378082 @ qq.com)
 * @date: 2022/12/20
 **/
@Repository
public class CategoryRelationRepository {
    private final CateRelationService cateRelationService;
    @Autowired
    public CategoryRelationRepository(CateRelationService cateRelationService){
        this.cateRelationService = cateRelationService;
    }

    public void removeByDescendant(int id){
        QueryWrapper<CateRelationPo> relationQueryWrapper = new QueryWrapper<>();
        relationQueryWrapper.eq("descendant", id);
        cateRelationService.remove(relationQueryWrapper);
    }
    public void removeByDescendants(List<Integer> ids){
        QueryWrapper<CateRelationPo> relationQueryWrapper = new QueryWrapper<>();
        relationQueryWrapper.in("descendant", ids);
        cateRelationService.remove(relationQueryWrapper);
    }

    public void saveBatch(List<CateRelationPo> insert){
        cateRelationService.saveBatch(insert);
    }
}
